/**
 * 评论
 */
$(function(){
	var userId = $(".user_id").attr("value"); 
	var info_id =$(".info_id").attr("value");
	var urlText=$(".urlText").val();
	var photoLink=$(".photo_link").attr("value");
	var username=$(".username").attr("value");
	var datetime=$(".datetime").attr("value");

	$("#commentbtn").click(function() {
		var commentMain=$(".CommentMain").val();
		if(commentMain == ""){
			alert("请输入评论内容再提交！");
		}else{
			$.ajax({
				url:urlText+"/comment/add_comment.do",
				data:{
					user_id:userId,
					object_id:info_id,
					object_type:"4",
					content:commentMain,
					datetime:datetime,
					username:username,
					photo_link:photoLink
				},
					success:function(data){
					$("#afterCommentDiv").before('<div id="afterCommentDiv" class="afterCommentDiv">'
							+ '<img alt="30x30" class="img-circle img-opcaity" style="width:50px;height:50px" src="'+photoLink+'">'
							+ '<p>'+username+'</p>'
							+ '<p>'+commentMain+'</p>'
							+ '<p style="color:#999">发布于：<fmt:formatDate value="'+datetime+'" pattern="yyyy-MM-dd"/></p>'
							+ '</div>'); 		 
				},
				error:function(XMLHttpRequest, textStatus, errorThrown){
					alert(XMLHttpRequest);
				}
			});
		}
	});
});